# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=cairo
pkgver=1.18.0
pkgrel=0
pkgdesc="A vector graphics library"
url="https://cairographics.org/"
arch="all"
options="!check"  # Recursive dependency on gtk+2.0 for check.
license="LGPL-2.1-or-later OR MPL-1.1"
depends_dev="
	$pkgname-tools=$pkgver-r$pkgrel
	fontconfig-dev
	freetype-dev
	libxext-dev
	libxrender-dev
	pixman-dev
	xcb-util-dev
	"
makedepends="
	$depends_dev
	expat-dev
	glib-dev
	gtk-doc
	libpng-dev
	meson
	zlib-dev
	"
subpackages="
	$pkgname-dbg
	$pkgname-static
	$pkgname-dev
	$pkgname-doc
	$pkgname-gobject
	$pkgname-tools
	"
source="https://gitlab.freedesktop.org/cairo/cairo/-/archive/$pkgver/cairo-$pkgver.tar.bz2
	musl-stacksize.patch
	"

# secfixes:
#   1.17.4-r1:
#     - CVE-2019-6462
#   1.16.0-r2:
#     - CVE-2020-35492
#   1.16.0-r1:
#     - CVE-2018-19876

build() {
	abuild-meson \
		-Db_lto=true \
		-Ddefault_library=both \
		-Dgtk_doc=true \
		-Dtests="$(want_check && echo enabled || echo disabled)" \
		. output
	meson compile -C output
}

check() {
	meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

gobject() {
	pkgdesc="$pkgdesc (gobject bindings)"

	amove usr/lib/libcairo-gobject.so.*
}

tools() {
	pkgdesc="$pkgdesc (development tools)"

	amove usr/bin
	amove usr/lib/cairo/libcairo-trace.*
}

sha512sums="
bd702f3b64061f8add954c243c9b59f5d44271adfa76d997941ddab629ff8018c2a1d3368edf2362573e0018c342c61483de58240c63e15e1e6035d2511d3e40  cairo-1.18.0.tar.bz2
86f26fe41deb5e14f553c999090d1ec1d92a534fa7984112c9a7f1d6c6a8f1b7bb735947e8ec3f26e817f56410efe8cc46c5e682f6a278d49b40a683513740e0  musl-stacksize.patch
"
